<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <title>详情页</title>

    <style type="text/css">
        body,
        html {
            overflow-x: hidden;
            background-color: #F7F7F7;
        }

        header {
            color: #FFFFFF;
            background: -webkit-linear-gradient(left top, #0F9BEB, #1569C8);
            /* Safari 5.1 - 6.0 */
            background: -o-linear-gradient(bottom right, #0F9BEB, #1569C8);
            /* Opera 11.1 - 12.0 */
            background: -moz-linear-gradient(bottom right, #0F9BEB, #1569C8);
            /* Firefox 3.6 - 15 */
            background: linear-gradient(to bottom right, #0F9BEB, #1569C8);
            background: -webkit-linear-gradient(left top, #0F9BEB, #1569C8);
            /* 标准的语法*/
            box-shadow: 0 0px 7px #0c5ebb;
        }

        .aui-bar-nav {
            top: 0;
            line-height: 2.25rem;
            background-color: #03a9f4;
            color: #ffffff;
            padding: 15px 0 2px 0;
        }

        .editor {
            padding: 0 0rem;
            width: 2.5rem;
            height: 1.05rem;
            line-height: 1.05rem;
            text-align: center;
            border-radius: 0.15rem;
            /*margin: 0 0.75rem 0 0px;*/
            display: inline-block;
            border: 0.05rem solid #fff;
            height: auto !important;
            padding: 0.05rem;
        }

        .aui-bar-nav .aui-btn {
            line-height: initial !important;
        }

        .aui-pull-right img {
            max-width: 48%;
            display: block;
        }

        .huilv-li {
            padding-left: 0 !important;
        }

        .huilv-inner {
            padding-right: 0 !important;
            padding-bottom: 0 !important;
        }

        .huilv-row {
            /*margin: 15px 0 1px 0;*/
            border-bottom: 1px solid #e6e6e6;
            /*border-top: 1px solid #e6e6e6;*/
        }

        .huilv-yingkui-block {
            border-right: 1px solid #E6E6E6;
        }

        .huilv-yingkui-block,
        .huilv-bili-block {
            padding: 0 !important;
            margin: 0.45rem auto !important;
        }

        p.title {
            margin-top: 0.5rem !important;
            font-size: 0.6rem !important;
            line-height: 0.6rem !important;
            color: #666;
        }

        p.message {
            font-size: 0.8rem;
            color: #000;
            color: #e61a0c;
            color: #03a626;
        }

        a.aui-list-item-inner.aui-list-item-arrow {
            border-bottom: 0.05rem solid #EEEEEE !important;
        }

        li.aui-list-item.btcTitle {
            padding-right: 0.75rem !important;
        }

        .aui-row.aui-row-padded.huilv-row {
            height: 4.25rem;
        }

        .list-xinxi {
            margin-bottom: 0 !important;
        }

        .aui-content.aui-margin-b-15 {
            margin-bottom: 0 !important;
        }

        .more-p {
            height: 2.25rem;
            font-size: 0.7rem;
            padding-left: 15px;
            color: #999999;
            line-height: 45px;
        }

        .more-ul li > div,
        .jys-ul li > div {
            border-bottom: 1px solid #E6E6E6 !important;
        }

        .cjl-spans-content span {
            font-size: 0.6rem !important;
            color: #999999 !important;
        }

        section.aui-content {
            margin-bottom: 10px;
        }

        .aui-list .aui-list-item-inner {
            position: relative;
            min-height: 2.3rem;
            padding-right: 0rem !important;
            /*margin-right: 0.75rem;*/
        }

        .aui-list .aui-list-item-right,
        .aui-list-item-title-row em {
            max-width: 50%;
            text-align: -webkit-right;
        }

        .aui-grid .aui-iconfont {
            position: relative;
            z-index: 20;
            top: -0.85rem;
            height: 1.4rem;
        }

        p.share_title {
            padding-bottom: 0.75rem;
        }

        .aui-list-item-title span {
            display: inline-block;
            float: left;
        }

        .btcIcon {
            width: 1.25rem;
            height: 2.2rem;
            background-image: url(../../image/btn/setting_hlgl@2x.png);
            background-repeat: no-repeat;
            background-position: center;
            background-size: 1.25rem;
        }

        .aui-list-item-arrow.btcTitle {
            line-height: 2.2rem;
            padding-left: 0 !important;
            padding-right: 0 !important;
            margin-left: 0.75rem !important;
            margin-right: 0.75rem !important;
            background-image: none !important;
            border-bottom: 0.05rem solid #E6E6E6 !important;
        }

        .property {
            margin-left: 0.55rem;
            line-height: 2.25rem;
        }

        .aui-list-item {
            text-align: left;
        }

        #buyPrice div span {
            display: block;
        }

        .aui-media-list .aui-list-item-inner {
            display: block;
            padding-top: 0rem;
        }

        .aui-col-xs-6.huilv-yingkui-block {
            overflow: hidden;
        }

        div#yingkui {
            height: 3.25rem !important;
            width: 100%;
            margin: 0 auto;
        }

        #buyPrice {
            padding: 0 1.75rem;
        }

        #buyPrice div {
            text-align: center;
        }

        li {
            background-image: none !important;
        }

        li.aui-list-item.btcTitle {
            height: 2.3rem !important;
            line-height: 2.3rem !important;
        }

        div#buyPrice {
            display: block;
            height: 3.2rem !important;
        }

        .aui-list-item-title span {
            display: inline-block;
            float: left;
            height: 1.25rem !important;
            line-height: 1.25rem !important;
        }

        .btcTitle {
            /*position: relative;*/
            overflow: hidden;
            display: block !important;
            border-bottom: none !important;
        }

        .btcTitle span {
            float: left;
        }

        span.priceSpan-title,
        span.rangeSpan-title,
        span.percentSpan-title {
            color: #999999;
            font-size: 0.6rem;
            line-height: 0.6rem;
            margin-top: 0.75rem;
        }

        span.priceSpan-data,
        span.rangeSpan-data,
        span.percentSpan-data {
            color: #000;
            font-size: 0.8rem;
            line-height: 0.8rem;
            margin-top: 0.55rem !important;
        }

        .aui-list-item-arrow:before {
            position: absolute;
            top: 1rem;
            right: 0.95rem !important;
        }

        .aui-margin-b-15 {
            margin-bottom: 0.5rem !important;
        }

        .floatBtn {
            position: absolute;
            width: 2.2rem;
            height: 2.2rem;
            line-height: 2.2rem;
            text-align: center;
            border-radius: 50%;
            background: -webkit-linear-gradient(left top, #0F9BEB, #1569C8);
            box-shadow: 0.05rem 0 6px #1569C8;
            bottom: 1.4rem;
            right: 1.4rem;
        }

        .addIcon {
            width: 2.2rem;
            height: 2.2rem;
            line-height: 2.2rem;
            background-image: url(../../image/setting_add_add@2x.png);
            background-position: center;
            background-size: 1rem;
            background-repeat: no-repeat;
        }

        ul#propertyMsgUl {
            background-color: #f7f7f7;
        }

        li.btcMessageli {
            background-color: #FFFFFF !important;
            margin-bottom: 0.5rem;
            height: 6rem !important;
        }

        li.noDateNotes {
            background-color: #fff;
            height: 2rem;
            line-height: 2rem;
            text-align: center;
            font-size: 0.7rem;
            color: #e5e5e5;
        }
    </style>

</head>

<body>
<header class="aui-bar aui-bar-nav">
    <a href="../set/set.html" class="aui-pull-left aui-btn">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
    <div class="aui-title"><span>币资产</span></div>
    <div class="aui-pull-right aui-btn" onclick="toEditor()">
        <span class="editor">编辑</span>
    </div>

</header>

<section class="aui-content user-info aui-margin-b-15 list-xinxi">
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list">
            <li class="aui-list-item huilv-li">
                <div class="aui-list-item-inner aui-text-center huilv-inner">

                    <div class="aui-row aui-row-padded huilv-row">
                        <div class="aui-col-xs-6 huilv-yingkui-block">
                            <div class="aui-col-xs-8">
                                <p class="title">总资产</p>
                                <p class="message" id="zc"></p>
                            </div>
                        </div>
                        <div class="aui-col-xs-6 huilv-bili-block">
                            <div class="aui-col-xs-8">
                                <p class="title">总盈亏</p>
                                <p class="message" id="yk"></p>
                            </div>
                        </div>

                    </div>

                    <div class="aui-row aui-row-padded huilv-row">
                        <div class="aui-col-xs-6 huilv-yingkui-block">
                            <div class="aui-col-xs-8">
                                <p class="title">当日盈亏</p>
                                <p class="message" id="dryk"></p>
                            </div>
                        </div>
                        <div class="aui-col-xs-6 huilv-bili-block">
                            <div class="aui-col-xs-8">
                                <p class="title">当日盈亏比例</p>
                                <p class="message" id="drykbl"></p>
                            </div>
                        </div>

                    </div>
                </div>
            </li>
        </ul>
    </div>

</section>
<p class=" more-p"> 资产信息</p>
<section class="aui-content">
    <ul class="aui-list aui-list-in aui-margin-b-15" id="propertyMsgUl">
    </ul>
</section>
<div class="floatBtn" onclick="toAddCoin()"><span class="addIcon"></span></div>
</body>
<script src="../../script/api.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="../../script/aui-sharebox.js"></script>
<script src="../../jquery-2.1.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../script/tool.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

  var bizhichanList = JSON.parse(localStorage.getItem('bizhichanList')) || [];
  var headers = {};

  var ZC = 0
  var zhongZC = 0;
  var dangrYK = 0;
  console.log(JSON.stringify(bizhichanList))

  //	分享功能区块
  apiready = function () {
    api.parseTapmode();
    headers = {
      "appVersion": "1.0.0",
      "os": api.systemType,
      "osVersion": api.systemVersion
    }
  }
  ajax_fordata()

  function ajax_fordata() {
    var dataArr = [];

    for (let i of bizhichanList) {
      dataArr.push({
        name: i.tokenName,
        symbol: i.AbbreviationName
      })
    }
    var si = setInterval(function () {
      if (window.parent.headers != {}) {
        clearInterval(si)
        $.ajax({
          url: orginlink + '/allcoin/getCoinInfo',
          data: {
            coinArray: JSON.stringify(dataArr)
          },
          type: 'GET',
          headers: headers,
          contentType: "application/json",
          dataType: 'json',
          success: function (result) {
            if (result.code == 0) {
              for (let i of bizhichanList) {
                for (let x of result.result) {
                  zhongZC += x.priceCNY * i.number;
                  dangrYK += parseInt(x.changemoney);
                }
                if (i.moneyType == 1) {
                  ZC += i.money * i.number
                } else {
                  ZC += i.money
                }
              }
            }

            console.log(dangrYK)
            $("#zc").text(zhongZC)
            $("#yk").text(zhongZC - ZC)
            $("#dryk").text(dangrYK)
            $("#drykbl").text((dangrYK / zhongZC * 100 ) ? (dangrYK / zhongZC * 100 ) : 0 + "%")
            init(result.result)


            if (zhongZC > ZC) {
              $("#zc").css('color', getRiseColor());
            } else if (zhongZC == ZC) {
              $("#zc").css('color', "#000");
            } else {
              $("#zc").css('color', getFallColor());
            }
            if ((zhongZC - ZC) > 0) {
              $("#yk").css('color', getRiseColor());
            } else if ((zhongZC - ZC) == 0) {
              $("#yk").css('color', "#000");
            } else {
              $("#yk").css('color', getFallColor());
            }
            if (dangrYK > 0) {
              $("#dryk").css('color', getRiseColor());
              $("#drykbl").css('color', getRiseColor());
            } else if (dangrYK == 0) {
              $("#dryk").css('color', "#000");
              $("#drykbl").css('color', "#000");
            } else {
              $("#dryk").css('color', getFallColor());
              $("#drykbl").css('color', getFallColor());
            }
          }
        });
      }
    }, 100)
  }

  function backBefore() {
    window.history.go(-1);
  }

  function toEditor() {
    window.location.href = "detail-bianji.html";
  }

  //浮动按钮前往“添加币资产”
  function toAddCoin() {
    window.location.href = "detail-addzichanl.html";
  }

  function init(result) {
    if (!bizhichanList || bizhichanList.length == 0) {
      $("#propertyMsgUl").append('<li class="noDateNotes"> 暂无添加</li>');
    } else {
      for (let i = 0; i < bizhichanList.length; i++) {
//        var bi = {
//          tokenName: i.tokenName,
//          AbbreviationName: i.AbbreviationName,
//          number: i.number,
//          money: i.money,
//          moneyType: i.moneyType,
//          address: i.address
//        }
        //addToken取出
        var tokenName = bizhichanList[i].tokenName + "(" + bizhichanList[i].AbbreviationName + ")";
        var sumProperty = result[i].priceCNY * bizhichanList[i].number;

        $("#propertyMsgUl").append(
          '<li class="btcMessageli">' +
          '<div class="aui-list-item btcTitle">' +
          '<span class= "btcIcon" ></span>' +
          '<span class="property">' + tokenName + '</span>' +
          '</div>' +
          '<div class="buyPrice" id="buyPrice">' +
          '<div class="aui-col-xs-4 priceDiv">' +
          '<span class="priceSpan-title">资产价值</span>' +
          '<span class="priceSpan-data">' + sumProperty + '</span>' +
          '</div>' +
          '<div class="aui-col-xs-4 rangeDiv">' +
          '<span class="rangeSpan-title">盈亏</span>' +
          '<span class="rangeSpan-data" style="color:' + (result[i].percentChange > 0 ? getRiseColor() : result[i].percentChange == 0 ? '#000' : getFallColor()) + '">' + result[i].changemoney * bizhichanList[i].number + '</span>' +
          '</div>' +
          '<div class="aui-col-xs-4 percentDiv">' +
          '<span class="percentSpan-title">比例</span>' +
          '<span class="percentSpan-data" style="color:' + (result[i].changemoney > 0 ? getRiseColor() : result[i].changemoney == 0 ? '#000' : getFallColor()) + '">' + result[i].percentChange + '%</span>' +
          '</div>' +
          '</div>' +
          '</li>');

      }
    }
  }

  function addBox(result) {
    $.each(result.result, function (index, obj) {
      var oBizhong = obj['name'];
      var oJiaoyisuo = obj['exchangeId']
      var oJiage = obj['priceCNY'];
      var oJgzfPer = obj['roseCny'];
      var oJgzfPic = obj['changeCnyPrice'];
      var oDuihuan = obj['price'] + obj['symbol'];
      var oXdzhangfuPer = obj['rose'];
      var oXdzhangfuPic = obj['changePrice']

      var x = getjysName(oJiaoyisuo)

      console.log(typeof oJiage + oJiage)

      //      oJiage = oJiage.substring(0, 6);
      oJgzfPic = oJgzfPic.substring(0, 6);
      oDuihuan = oDuihuan.substring(0, 6)
      oXdzhangfuPic = oXdzhangfuPic.substring(0, 6);

      //涨幅 百分小数取一位预处理
      oJgzfPer = changeTwoDecimal_f(oJgzfPer * 100);
      oXdzhangfuPer = changeTwoDecimal_f(oXdzhangfuPer * 100);
      //数值前添加符号表示涨+跌-
      if (oJgzfPer > 0) {
        oJgzfPer = '+' + oJgzfPer;
      }

      $('#bizhongul').append('<li class="bz-nameli" onclick="todetail(' + index + ')">' + '<span class="bz-name-img"></span>' + '<span class="bz-name-title">' + oBizhong + '</span>' + '</li>');
      $('#jysul').append('<li class="jys-nameli" onclick="todetail(' + index + ')"><span>' + x + '</span></li>');
      $('#jiageul').append('<li class="jg-nameli" onclick="todetail(' + index + ')"><span>￥' + oJiage + '</span>' + '</li>');
      $('#zhangfuul').append('<li class="zf-nameli" onclick="todetail(' + index + ')"><span class="zf-huilv">' + oJgzfPer + '%</span><span class="zf-zhishu"><b>￥</b>' + oJgzfPic + '</span>' + '</li>')

      $('#daibiul').append('<li onclick="todetail(' + index + ')"><span>' + oDuihuan + '</span></li>');
      $('#xdzhangfuul').append('<li class="xdzf-li" onclick="todetail(' + index + ')"><span class="xdzf-span">' + oXdzhangfuPer + '%</span><span class="xdzf-jg-span"><b>￥</b>' + oXdzhangfuPic + '</span>' + '</li>')

      //数值判断涨跌后添加颜色
      if (oJgzfPer > 0) {
        $('.zf-huilv:eq(' + (index + mindex) + ')').css('color', '#e61303');
      } else if (oJgzfPer < 0) {
        $('.zf-huilv:eq(' + (index + mindex) + ')').css('color', '#03A626');
      } else {
        $('.zf-huilv:eq(' + (index + mindex) + ')').css('color', '#000000');
      }
      if (oXdzhangfuPer > 0) {
        $('.xdzf-span:eq(' + (index + mindex) + ')').css('color', '#e61303');
      } else if (oXdzhangfuPer < 0) {
        $('.xdzf-span:eq(' + (index + mindex) + ')').css('color', '#03A626');
      } else {
        $('.xdzf-span:eq(' + (index + mindex) + ')').css('color', '#000000');
      }
    })


    // mindex += result.result.length
  }
</script>

</html>
